package demo2;

import java.io.FileNotFoundException;
import java.util.Scanner;

public class test {




    public static void main4(String[] args) {
        int age=80;
        if(!(age>=18&&age<=100)){
            throw new RuntimeException("年龄需要设置在18-100之间");
        }
        System.out.println("你输入的这个年龄是正确的");
    }

    class AgeException extends FileNotFoundException {
        public AgeException(String message){
            super(message);
        }
    }








    public static void main(String[] args) throws ArithmeticException{
        f2();
    }

    public static void f2() throws ArithmeticException{
        int num1=1;
        int num2=0;
        int ret=num1/num2;
        System.out.println(ret);
    }



    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num=0;
        String inputer="";
        while(true){
            System.out.println("请输入一个整数：");
            inputer=scanner.next();
            try{
                num=Integer.parseInt(inputer);
                break;
            }
            catch(NumberFormatException e){
                System.out.println("你输入的不是一个整数");
            }
        }
        System.out.println("你输入的数值是："+num);
    }
    public static void main3(String[] args) {
        try {
            String name="程序设计";
            int num=Integer.parseInt(name);
            System.out.println(name);
        } catch (NumberFormatException e) {
            System.out.println(e.getMessage());
        }
        System.out.println("程序继续执行~~");
    }
}
